package com.struct.graph.game.body
{
	import com.collection.AbilityCollection;
	import com.utils.Collide;
	import com.utils.Utils;
	
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	public class PlayerBody extends BaseBody
	{
		private var bitmapData:BitmapData;
		
		private var txtName:TextField;
		private var txtLeft:TextField;
		private var bullet:BulletBody;//子弹
		
		public function PlayerBody(name:String, radius:int, left:int, attack:int, defense:int, quality:Number, bitmapData:BitmapData, width:Number, height:Number, damp:Number = 0.02, isHarm:Boolean = true, isMove:Boolean = true)
		{
			super(radius, left, attack, defense, quality, bitmapData, width, height, damp, isHarm, isMove);
			this.bitmapData = bitmapData;
			this.width = width;
			this.height = height;
			txtName = Utils.createTextField(this, -32, radius, name, 12, 0, true, TextFieldAutoSize.CENTER, 64);
			txtLeft = Utils.createTextField(this, -32, -height + radius * 2 - 20, left.toString(), 12, 0, true, TextFieldAutoSize.CENTER, 64);
			aa(0, 0);
			bullet = new BulletBody(this, 16, 32, 32);
			move = 100;
		}
		
		public function aa(x:int, y :int):void{
			bitMap.bitmapData = new BitmapData(64, 64);
			bitMap.bitmapData.copyPixels(bitmapData, new Rectangle(x, y, width, height), new Point());
			bitMap.x = -width / 2;
			bitMap.y = -height + radius * 2;
		}
		
		override public function validtorCollide2Destroy(collide:Collide):Boolean{
			var f:Boolean = super.validtorCollide2Destroy(collide);
			txtLeft.text = left.toString();
			return f;
		}
		
		public function getBullet(skill:Object):BulletBody{
			bullet.setting(skill.hurt + attack, skill.quality + quality, skill.move, skill.id);
			return bullet;
		}
	}
}